Skip to main content

Code Style

This document describes the code style guidelines that should be followed when working on the Bugfender project. These guidelines are designed to ensure that the code is consistent, easy to read, and maintainable.

Table of Contents

General Guidelines

When writing code for the Bugfender project, you should follow these general guidelines:

  • Consistency: Code should be consistent in style and formatting. This makes it easier to read and understand for other developers.
  • Readability: Code should be easy to read and understand. Use descriptive variable and function names, and add comments where necessary to explain complex logic.
  • Modularity: Code should be modular and reusable. Break down complex logic into smaller, more manageable functions and components.
  • Error Handling: Always handle errors gracefully. Use try/catch blocks where necessary and provide meaningful error messages to users.

JavaScript

When writing JavaScript code for the Bugfender project, you should follow these guidelines:

  • Use ES6: Use ES6 features such as arrow functions, template literals, and destructuring where possible.
  • Prefer const and let: Use const for variables that do not change and let for variables that do change.
  • Avoid Global Variables: Minimize the use of global variables to prevent naming conflicts and improve code maintainability.
  • Use Linting: We use ESLint and Prettier to enforce code style and formatting rules. Make sure to run linters before committing your changes.
  • Use tabs for indentation: Use tabs for indentation instead of spaces. Set your editor to use tabs for indentation.

Go

Go already has a built-in code formatter called gofmt, which automatically formats your code according to the official Go style guidelines. If your editor is configured to run gofmt on save, you should not need to worry about code formatting.

We use go modules for dependency management, so make sure to use go mod tidy to update your dependencies when necessary.